import { request } from "umi";

/** 获取调研表列表 */
export async function getSurveyList({ current, pageSize }: Partial<COMMON.PageParams>) {
  return request<COMMON.PageResult<PATIENT.SurveyInfo>>(`/api/question/survey/${current}/limit/${pageSize}`);
}

/** 添加调研表 */
export async function addSurvey(data: PATIENT.SurveyDetailInfo) {
  return request(`/api/question/survey`, {
    method: 'POST',
    data,
    headers: { Action_Id: '900901004' }
  });
}

/** 修改调研表 */
export async function editSurvey(survey_id: string, data: PATIENT.SurveyDetailInfo) {
  return request(`/api/question/survey/${survey_id}`, {
    method: 'PATCH',
    data,
    headers: { Action_Id: '900901005' }
  });
}

/** 获取调研表 */
export async function getSurveyDetail(survey_id: string) {
  return request<PATIENT.SurveyDetailInfo>(`/api/question/survey/${survey_id}`);
}

/** 删除调研表 */
export async function deleteSurvey(survey_id: string) {
  return request(`/api/question/survey/${survey_id}`, {
    method: 'DELETE',
    headers: { Action_Id: '900901006' }
  });
}


/** 获取随访列表 */
export async function getFollowUpList({ current, pageSize, ...params }: Partial<COMMON.PageParams & PATIENT.FollowUpInfo>) {
  return request<COMMON.PageResult<PATIENT.SurveyInfo>>(`/api/question/partake/${current}/limit/${pageSize}`, {
    params,
    headers: { Action_Id: '900901000' }
  });
}

/** 提交随访信息 */
export async function saveFollowUp(data: any) {
  return request(`/api/question/survey/result`, {
    method: 'POST',
    data,
    headers: { Action_Id: '900901001' }
  });
}

/** 删除随访记录 */
export async function deleteFollowUp(patient_id?: string, order_id?: string, survey_test_id?: string) {
  return request(`/api/question/partake/${patient_id}/${order_id}/${survey_test_id}`, {
    method: 'DELETE',
    headers: { Action_Id: '900901002' }
  });
}

/** 获取随访详情 */
export async function getFollowUpInfo(patient_id: string, order_id: string, survey_test_id: string) {
  return request<PATIENT.SurveyResultInfo>(`/api/question/survey/${patient_id}/${order_id}/${survey_test_id}/result`, {
    headers: { Action_Id: '900901003' }
  });
}

/** 添加参与者 */
export async function followUpPartake(data: any) {
  return request(`/api/question/partake`, {
    method: 'POST',
    data: data
  });
}

/** 查询参与者信息 */
export async function getFollowUpPartake(order_id: string) {
  return request(`/api/question/survey/of/order/${order_id}`);
}
